//
//  RecommendationViewController.m
//  IComic_Stone
//
//  Created by dlios on 15-3-21.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "RecommendationViewController.h"
#import "PosterFirstCell.h"
#import "PosterSecondCell.h"
#import "AFNetworking.h"
@interface RecommendationViewController ()<UITableViewDataSource, UITableViewDelegate>
@property(nonatomic, retain)UIView *backgroundView;
@property(nonatomic, retain)UITableView *totalTableView;
@property(nonatomic, retain)NSMutableArray *totalArr;
@end

@implementation RecommendationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor greenColor];
    
    //铺设一个背景视图backgroundView, 加到视图控制器的View上, 距离顶部100像素, 宽度与屏幕等宽, 高度与屏幕差100.
    self.backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, self.view.frame.size.height - 100)];
    self.backgroundView.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:self.backgroundView];
    [_backgroundView release];
    
    
    //检验tableView是否正确
    UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.backgroundView.frame.size.width, self.backgroundView.frame.size.width)];
    imageV.image = [UIImage imageNamed:@"T5R`ZA4C8%D41C16Q9XAP`L.jpg"];
    [self.backgroundView addSubview:imageV];
    [imageV release];
    
    
    //设置UItableView
    self.totalTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.backgroundView.frame.size.width, self.backgroundView.frame.size.height) style:UITableViewStylePlain];
    self.totalTableView.delegate = self;
    self.totalTableView.dataSource = self;
    self.totalTableView.backgroundColor = [UIColor clearColor];
    [self.backgroundView addSubview:self.totalTableView];
    [_totalTableView release];

    //总体cell的注册
    [_totalTableView registerClass:[PosterFirstCell class] forCellReuseIdentifier:@"reuse1"];
    
    [_totalTableView registerClass:[PosterSecondCell class] forCellReuseIdentifier:@"reuse3"];
    
    //背景图片的设置,用来检验tableView是否正确
    UIView *backgroundImage = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.backgroundView.frame.size.width, self.backgroundView.frame.size.height / 3)];
    backgroundImage.backgroundColor = [UIColor clearColor];
    //设置TableView的顶部高度和样式
    [_totalTableView setTableHeaderView:backgroundImage];
    [backgroundImage release];
    
    
    
//    NSString *url = [NSString stringWithFormat:@"%@",KComicClassifyList];
//    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
//    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
//    [manager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        
//        NSMutableArray *data = [responseObject objectForKey:@"data"];
//        
//        // 数据处理
//        
//        
//    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        
//        NSLog(@"%@",error);
//    }];
}

//UITableView 的协议方法,用来设置cell的个数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 20;
}
////UITableView 的协议方法,用来设置cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.item == 0) {
        PosterFirstCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse1"];
        //cell.backgroundColor = [UIColor yellowColor];
        cell.backgroundColor = [UIColor clearColor];
        //点击cell没反应
        //cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        return cell;

    }else{
        PosterSecondCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse3"];
        //cell.backgroundColor = [UIColor blueColor];
        
        return cell;
    }
    
    
}
//设置cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 200;
}
//选中cell的时候,调用这个方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //选中cell颜色改变后再变回原来的颜色
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
